//
//  LCAutomaticBackupVC.m
//  LongChain
//
//  Created by FengZi on 2018/4/1.
//  Copyright © 2018年 FengZi. All rights reserved.
//

#import "LCAutomaticBackupVC.h"
#import "LCAutomaticBackupCell.h"
@interface LCAutomaticBackupVC ()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>

@property (nonatomic, strong) NSArray *datas;

@end

@implementation LCAutomaticBackupVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    _datas = @[
               @[@"自动备份照片",@"自动备份视频"],
               @[@"选择备份相册"]
               ];
}


- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath {
    if ([kind isEqualToString:UICollectionElementKindSectionFooter]) {
        UICollectionReusableView *footer = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"backupDesFooter" forIndexPath:indexPath];
        return footer;
    }
    return nil;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {

    NSInteger row = indexPath.row;
    NSInteger section = indexPath.section;

    LCAutomaticBackupCell *automaticBackupCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"autoBackupCell" forIndexPath:indexPath];
    NSArray *itemDatas = self.datas[section];
    if (itemDatas.count > row ) {
        [automaticBackupCell ls_updateAutomaticBackupWithParameter:itemDatas[row]];
    }
    return automaticBackupCell;
}

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return _datas.count;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {

    NSArray *itemArr = _datas[section];
    return itemArr.count;
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    return CGSizeMake(SWidth, 50);
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section {
    
    CGFloat footHeight = (section == 0) ? 0 : 100;
    return CGSizeMake(SWidth, footHeight);
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
